﻿using Microsoft.Win32;
using System.Windows.Forms;

namespace LAura
{
    public class Settings
    {
        #region Member

        private readonly RegistryKey m_registryKeyApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

        #endregion



        #region Properties

        public bool RunFromStartup { get; set; }

        #endregion



        #region Constructor

        public Settings()
        {
            RunFromStartup = false;
        }

        #endregion



        #region Methods

        public void ReadRegistry()
        {
            RunFromStartup = m_registryKeyApp.GetValue("LAura") != null;
        }

        public void WriteRegistry()
        {
            if (RunFromStartup == false)
            {
                m_registryKeyApp.DeleteValue("LAura", false);
            }
            else
            {
                m_registryKeyApp.SetValue("LAura", Application.ExecutablePath);
            }
        }

        #endregion
    }
}
